from django.db import models


# 杂豆表
class bean(models.Model):
    Bid = models.IntegerField(primary_key=True)
    Bname = models.CharField(max_length=255)
    class Meta:
        db_table='bean'


# 病虫害表
class pest(models.Model):
    Pid = models.IntegerField(primary_key=True)
    NameZHCN = models.TextField(null=True, blank=True, default="")
    NameEng = models.TextField(null=True, blank=True, default="")
    Synonyms = models.TextField(null=True, blank=True, default="")
    Introduction = models.TextField(null=True, blank=True, default="")
    Pathogen = models.TextField(null=True, blank=True, default="")
    Cycle = models.TextField(null=True, blank=True, default="")
    OFactor = models.TextField(null=True, blank=True, default="")
    Morphology = models.TextField(null=True, blank=True, default="")
    Habits = models.TextField(null=True, blank=True, default="")
    CMethod = models.TextField(null=True, blank=True, default="")
    DamageSym = models.TextField(null=True, blank=True, default="")
    Ptype = models.IntegerField(default=1)
    Oneimg = models.CharField(max_length=255,null=True, blank=True, default="")
    class Meta:
        db_table='pest'



# 识别记录表
class recognition(models.Model):
    Rid = models.AutoField(primary_key=True)
    Uid = models.IntegerField(blank=True, null=True)
    # Pid = models.IntegerField(null=True, blank=True, default=1)
    # Score = models.FloatField(null=True, blank=True, default=0.5)
    Result=models.CharField(max_length=6000,null=True, blank=True,default="")
    # Rtime=models.CharField(max_length=255,null=True, blank=True)
    Rtime=models.DateTimeField(null=True,blank=True)
    Rimg=models.CharField(max_length=255,null=True, blank=True,default="")
    class Meta:
        db_table='recognition'

# 视图
class view_influence_pest_abs(models.Model):
    vid= models.IntegerField(primary_key=True)
    Pid = models.IntegerField()
    NameZHCN = models.TextField(null=True, blank=True, default="")
    NameEng = models.TextField(null=True, blank=True, default="")
    Synonyms = models.TextField(null=True, blank=True, default="")
    Introduction = models.TextField(null=True, blank=True, default="")
    Pathogen = models.TextField(null=True, blank=True, default="")
    Cycle = models.TextField(null=True, blank=True, default="")
    OFactor = models.TextField(null=True, blank=True, default="")
    Morphology = models.TextField(null=True, blank=True, default="")
    Habits = models.TextField(null=True, blank=True, default="")
    CMethod = models.TextField(null=True, blank=True, default="")
    DamageSym = models.TextField(null=True, blank=True, default="")
    Ptype = models.IntegerField(default=1)
    Bid = models.IntegerField()
    Bname = models.CharField(max_length=255)
    Oneimg = models.CharField(max_length=255,null=True, blank=True, default="")
    class Meta:
        abstract = True

class view_influence_pest(view_influence_pest_abs):
  class Meta:
    managed = False
    db_table = 'view_influence_pest'

